define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {

    var Controller = {
        index: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'mul/mission/index',
                    add_url: 'mul/mission/add',
                    edit_url: 'mul/mission/edit',
                    del_url: 'mul/mission/del',
                    multi_url: 'mul/mission/multi',
                    table: 'mul_mission',
                }
            });

            var table = $("#table");

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                sortName: 'id',
                columns: [
                    [
                        {checkbox: true},
                        {field: 'id', title: __('Id')},
                        {field: 'goods', title: __('Goods')},
                        {field: 'goods_price', title: __('Goods_price'), operate: false},
                        {field: 'title', title: __('Title')},
                        {field: 'content', title: __('Content'), operate: false},
                        {field: 'num', title: __('Num'), operate: false},
                        {field: 'remain_num', title: __('Remain_num'), operate: false},
                        {field: 'fee', title: __('Fee'), operate: false},
                        {field: 're_buy_fee', title: __('Re_buy_fee'), operate: false},
                        {field: 'status', title: __('Status'), searchList: __('Job_statusa'),},
                        {field: 'create_time', title: __('Create_time'), formatter: Table.api.formatter.datetime, operate: false},
                        {field: 'end_time', title: __('End_time'), formatter: Table.api.formatter.datetime, operate: false},
                        {field: 'boss_name', title: __('Boss_name')},
                        {field: 'boss_tel', title: __('Boss_tel')},
                        {field: 'boss_addr', title: __('Boss_addr'), operate: false},
                        {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate,
                        buttons: [
                            {name: 'name1',
                                text: '详情',
                                title: '详情',
                                icon: 'fa fa-list',
                                classname: 'btn btn-xs btn-primary btn-dialog',
                                url: 'mul/mission/lists',
                            },
                            {
                                name:'url',
                                text:'链接地址',
                                title: '链接地址',
                                icon: 'fa fa-anchor',
                                classname: 'btn btn-info btn-xs btn-dialog',
                                url: 'mul/mission/url'
                            }
                            ]
                        }
                    ]
                ]
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        add: function () {
            Controller.api.bindevent();
        },
        edit: function () {
            Controller.api.bindevent();
        },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            }
        }
    };
    return Controller;
});